<%@page import="java.util.Calendar"%>
<%@page import="java.util.GregorianCalendar"%>
x<%-- 
    Document   : modifierTableau
    Created on : 4 mai 2012, 14:55:41
    Author     : Morgan
--%>

<%@page import="Tableau.Tableau"%>
<%@page import="Tableau.TableauFacadeLocal"%>
<%@page import="javax.naming.InitialContext"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%    
    int flagError = 0;
    Long id = new Long(0);
    Tableau tableau = null;
    GregorianCalendar cal = new GregorianCalendar();
        
    try
    {
        id = new Long(request.getParameter("id"));
    }
    catch(Exception e){
        flagError = -1;
    }
    
    if(flagError == 0)
    {
        InitialContext ctx = new InitialContext();
        TableauFacadeLocal tableaufacadeLocal = (TableauFacadeLocal) ctx.lookup("java:global/TP-Personne-EJB/TP-Personne-EJB-ejb/TableauFacade!Tableau.TableauFacadeLocal");
        
        tableau = tableaufacadeLocal.find(id);
    }
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="styles.css" type="text/css" />
    </head>
    <body>
        <jsp:include page="menuNavigation.jsp"/>
        
        <div class="content">
            <h1>Modifier Tableau</h1>
            
            <% if(flagError == 0)
                {
            %>
               <br/>
               <form action="enregistrerModificationTableau.jsp" method="post">
                <table>
                    <tr>
                    <td>Descriptif</td>
                    <td><textarea name="description"><%= tableau.getDescription() %></textarea></td>
                    </tr>
                    <td>Date de fin (année)</td>
                    <td><input type="text" name="annee" size="27" value="<%= cal.get(Calendar.YEAR) %>"/></td>
                    <td>Date de fin (mois)</td>
                    <td><input type="text" name="mois" size="27" value="<%= cal.get(Calendar.MONTH) %>"/></td>
                    <td>Date de fin (jour)</td>
                    <td><input type="text" name="jour" size="27" value="<%= cal.get(Calendar.DAY_OF_MONTH) %>"/></td>
                    </tr>
                    <tr>
                    <td>Date de fin (heure)</td>
                    <td><input type="text" name="heure" size="27" value="<%= cal.get(Calendar.HOUR_OF_DAY) %>"/></td>
                    <td>Date de fin (minute)</td>
                    <td><input type="text" name="minutes" size="27" value="<%= cal.get(Calendar.MINUTE) %>"/></td>
                    </tr>
                    <tr>
                    <td>Prix de vente initial</td>
                    <td><input type="text" name="prixDeb" size="27" value="<%= tableau.getPrixDepart() %>"/></td>
                    </tr>
                    <tr>
                    <td><input type="submit" value="Envoyer" /></td>
                    </tr>
                </table>
                <input type="hidden" name="id" value="<%= tableau.getId() %>"/>
                
            </form>
            <%}%>
        </div>
    </body>
</html>
